import request from '@/utils/request'

export function getActivityListApi(params: any) {
  return request<BaseResponseWithArray<defs.admin.Activity>>({
    url: '/api/activity',
    method: 'get',
    params,
  })
}

export function getActivityShowApi(id: number | string | undefined) {
  return request<
    Required<
      defs.admin.ActivityShowDto & {
        qrcode: string
      }
    >
  >({
    url: `/api/activity/show/${id}`,
    method: 'get',
  })
}

export function addActivityApi(data: Partial<defs.admin.CreateActivityRequest>) {
  return request<defs.admin.Activity>({
    url: '/api/activity',
    method: 'post',
    data,
  })
}

export function editActivityApi(id: number | string | undefined, data: defs.admin.UpdateActivityRequest) {
  return request<Array<number>>({
    url: `/api/activity/${id}`,
    method: 'put',
    data,
  })
}

export function delActivityApi(id: string) {
  return request<number>({
    url: `/api/activity/${id}`,
    method: 'delete',
  })
}

export function getSmsLoginApi() {
  return request<defs.admin.SmsTemplate[]>({
    url: `/api/activity/smsLogin`,
    method: 'get',
  })
}

export function getCitySelectApi(params: any) {
  return request<any[]>({
    url: `/api/activity/city`,
    method: 'get',
    params,
  })
}

export function getActivityCopyApi(data: defs.admin.CopyActivityDto) {
  return request<defs.admin.Activity>({
    url: `/api/activity/copy`,
    method: 'post',
    data,
  })
}

export function getActivityPublishApi(id: any) {
  return request<defs.admin.Activity>({
    url: `/api/activity/publish/${id}`,
    method: 'put',
  })
}

export function getActivityAllApi() {
  return request<
    {
      id: number
      title: string
    }[]
  >({
    url: `/api/activity/all`,
    method: 'get',
  })
}
